home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / xlist105.lha / xlist1.05 / xListing.sh < prev   
Text File  |  1995-10-08  |  3KB  |  163 lines

  1. # This script is Public Domain => You should Modify it !!!
  2. # It makes a recursive listing of a dir using xList
  3.  
  4. # main:
  5.  
  6. if $_version < 520
  7.     echo "This script needs at least Csh 5.20"
  8.     return 0
  9. endif
  10.  
  11. echo "Csh script for xList 1.05"
  12.  
  13. if -v 1                        # if arg detected
  14.     if -nd $1                # if arg is not a dir
  15.       set arg1 @filereq( "Select a directory to scan:" ) # popup FileReq.
  16.       if $arg1 = ""
  17.         echo "*** No dir selected."
  18.         return 0
  19.       endif
  20.     else                    # else it is a dir
  21.       set arg1 $1                # store dir in var 2
  22.     endif
  23. else                        # no args: popup filerequester
  24.     set arg1 @filereq( "Select a directory to scan:" )
  25.     if $arg1 = ""
  26.         echo "*** No dir selected."
  27.         return 0
  28.     endif
  29. endif
  30.  
  31. label mychkdir            # going to check if it is really a dir
  32.  
  33. if -nd $arg1
  34.     set arg1 @filereq( "Select a directory to scan:" )
  35.     goto mychkdir
  36. endif
  37.  
  38. date -s
  39. resident c:xList >nil:
  40.  
  41. goto init_aliases
  42. label init1_done
  43. goto init_variables
  44. label init2_done
  45.  
  46. echo Scanning dir...
  47. ls >t:x2 -cghz "%m%-16n%.5w  " $arg1        # building index
  48. init
  49. tackon wildcard $arg1 ".../*"
  50. ls -cqhnd $wildcard | readfile alldirs        # finding dirs and subdirs
  51. foreach i ( $alldirs ) "cmplx $i"
  52. end
  53.  
  54. return 0
  55.  
  56. ###########
  57.  
  58. # subroutines:
  59.  
  60. label init_aliases
  61.  
  62. set stk ""
  63. alias  pushd "%a set stk $_cwd @subwords( $stk 1 10 );\\cd $a
  64. alias  popd  "\\cd @first( $stk );set stk @subwords( $stk 2 10 )
  65.  
  66. alias init {
  67. echo "" >$dest2
  68. echo -n >>$dest2 "                        Listing on: "
  69. day $dest2
  70. echo >>$dest2 ""
  71. }
  72. # insert in the alias above 'type >$dest2 "my_intro"'
  73. #
  74.  
  75. alias day {
  76. %f 
  77. unset dat2
  78. echo >env:dat2 `date`
  79. strlen slen $dat2
  80. dec slen 9
  81. strleft dat2 $dat2 $slen
  82. echo >>$f $dat2
  83. delete >nil: env:dat2
  84. }
  85.  
  86. alias end {
  87. echo `date -r` >env:da1
  88. echo @nameroot( $da1 ) >env:da2
  89. echo Elapsed time: @rpn( $da2 60 / ) min @rpn( $da2 60 % ) s.
  90. echo >>$dest2 Total number of files: $ntotal
  91. echo >>$dest2 ""
  92. echo >>$dest2 "--------------------------------- ·I·N·D·E·X· ---------------------------------
  93. cat >>$dest2 t:x2
  94. echo >>$dest2 "-------------------------------------------------------------------------------
  95. echo Total number of files: $ntotal
  96. cat >>$dest2 $dest
  97. delete >nil: env:da1 env:da2 $dest t:x2 t:c1
  98. shcrunch
  99. resident -r xList >nil:
  100. unset alldirs choice wildcard dat2 dummy dest dest2 nli nline1 ntotal packer 2 tmp slen
  101. return 0
  102. }
  103.  
  104. # insert 'type >>$dest2 "my_endtext"' in the alias above, before 'shcrunch'
  105. #
  106.  
  107.  
  108. alias shcrunch {
  109. if -f c:xpk
  110.     set packer 1
  111.     goto crunching
  112. else
  113.     if -f c:packx
  114.         set packer 2
  115.         goto crunching
  116.     endif
  117. endif
  118.  
  119. return 0
  120.  
  121. label crunching
  122.     echo -n "Crunch the list (with xpkNUKE) ? (y/N): "
  123.     input -r choice
  124.     if -n $choice = y
  125.         echo ""
  126.         return 0
  127.     else
  128.         echo Crunching...
  129.         if $packer = 1
  130.             c:xpk -m NUKE $dest2
  131.         else
  132.             c:packx $dest2 lib=nuke
  133.         endif
  134.     endif
  135. }
  136.  
  137. alias cmplx {
  138. %i 
  139. echo $i
  140. xList >>$dest $i LF=4 DL
  141. inc ntotal $xltotal
  142. label endloop
  143. }
  144.  
  145. #goto nocomms # -(2)-
  146. label commsdone
  147. goto init1_done
  148.  
  149.  
  150. label init_variables
  151. set dest2 ram:Listing.txt
  152. set dest t:listx
  153. set tmp t:c1
  154. echo -n >$dest ""
  155. echo -n >$dest2 ""
  156. echo -n >$tmp ""
  157. set ntotal 0
  158. set dummy yes
  159. goto init2_done
  160.  
  161. # tHanX for reading this up to the end, mate !
  162. # *** Signoff: Reez, the mad modulelister (&raytracoder)
  163.